#include "stdafx.h"

#include "oil_model.h"
#include "parameters_model.h"
#include "common.h"

OilModel::OilModel(QWeakPointer<Common> _common, const QString &_name)
	: common(_common), name(_name)
{
	init_model();
}


OilModel::~OilModel(){}

void OilModel::init_model(){
	//0 - combobox/boolean
	//1 - spinbox
	//2 - textbox
	//3 - label

	QString common_parameter = "COMMON";

	model = QSharedPointer<ParametersModel>(new ParametersModel(this));
	model->addItem(common_parameter, "NAME", name, "", 2, 0, "test1");
	model->addItem(common_parameter, "DENSITY", 0, "kg/m3", 1, 0, "test2");
	model->addItem(common_parameter, "VISCOSITY/DINAMIC", 0, "CP", 1, 0, "test4");
	model->addItem(common_parameter, "VISCOSITY/KINEMATIC", 0, "-", 1, 0, "kinematic viscosity");
    model->addItem(common_parameter, "SVPRESSURE", 0, "Pa", 1, 0, "saturated vapour pressure");
	model->addItem(common_parameter, "SOUND SPEED", 0, "km/h", 1, 0, "SOUND SPEED");
}

void OilModel::update_parameters(){
	common.data()->getParametersWidget().data()->setItemDelegate(new Delegate(common.data()->getParametersWidget()));
}
